<style lang="less">
    @import '../../styles/common.less';
    @import '../tables/components/table.less';
</style>
<template>
    <div>
        <Table :loading="loading" refs="table1"  :data="Message" :columns="columnsList"></Table>
        <Page :total="pageNum" :page-size="pageSize"  style="text-align: center;margin-top: 15px;"  @on-change="pageChange"></Page>
    </div>
</template>
<script>
    import $http from '../../utils/axiosWrap'
    import canEditTable from '../tables/components/canEditTable.vue'
    import Cookies from 'js-cookie';

    export default {
        data () {
            return {
                loading: true,
                Message: [],
                pageSize: 10,
                columnsList: [
                    {
                        title: '序号',
                        width: 80,
                        align: 'center',
                        render: (h, params) => {
                            return  params.index + (this.initPage- 1) * this.pageSize + 1
                        }
                    },
                    {
                        title: '管理员姓名',
                        align: 'center',
                        key: 'sysname',
                        editable: true
                    },
                    {
                        title: '管理员电话',
                        align: 'center',
                        key: 'sysphone',
                        editable: true
                    },
                    {
                        title: '用户姓名',
                        align: 'center',
                        key: 'name',
                        editable: true
                    },
                    {
                        title: '用户电话',
                        align: 'center',
                        key: 'phone',
                        editable: true
                    },
                    {
                        title: '修改前的积分',
                        align: 'center',
                        key: 'oldIntegral',
                        editable: true
                    },
                    {
                        title: '修改后的积分',
                        align: 'center',
                        key: 'totalIntegral',
                        editable: true
                    },
                    {
                        title: '修改时间',
                        align: 'center',
                        width: 160,
                        render: (h, params) => {
                            if(params.row.updateTime){
                                return params.row.updateTime.replace(/\T/g, ' ').substring(0,19)
                            }else{
                                return ''
                            }
                        }
                    },
                    {
                        title: '备注',
                        align: 'center',
                        key: 'remark',
                        editable: true
                    }
                ],
                name: '',
                phone: '',
                pageNum: 1,
                initPage: 1
            }
        },
        created: function () {
            this.load()
        },
        methods: {
            pageChange(index){
                this.initPage = index
                this.loading = true
                this.load ()
            },
            load (){
                let _this = this
                let params = new URLSearchParams()
                params.append('pno',_this.initPage)
                $http.post('/backgroundUser/listSysIntegal',params).then(function (res) {
                    if (res.suc) {
                        _this.Message = res.result.list
                        _this.pageNum = res.result.totalRow
                    }else{
                        if(res.msg == "请先登录"){
                            _this.$Message.error('请重新登录！');
                        }else{
                            _this.$Message.error(res.msg);
                        }
                    }
                    _this.loading = false
                })
            }
        }
    }
</script>
<style>
    .userListInfo{
        display: inline-block;
        width: 120px;
    }
    .userListInfoWrap p{
        line-height: 26px;
    }
</style>

